<?php
	date_default_timezone_set('America/New_York');
	require("globals.php");
	session_start();
	enforceLogInPolicy();
	
	if($_SERVER['REQUEST_METHOD'] == 'POST'):
		checkForLogOutSubmit();
	elseif($_SERVER['REQUEST_METHOD'] == 'GET'):
		
	endif;
	
	function enforceLogInPolicy()
	{
		if(userIsLoggedIn()):
			$username = $_SESSION['username'];
			echo "Welcome, $username.<br/ >";
		else:
			//echo "Redirecting to login page.";
			header("location: /proj1/login/login.php");
		endif;
	}
	
	function checkForLogOutSubmit()
	{
		if(isset($_POST['LogoutSubmit'])):
			destroySession();
			forgetRememberMeCookie();
		else:
			return;
		endif;
	}
?>
<a href="/proj1/index.php">Home Page</a>
<div style="float:right;">
	<form action="/proj1/index.php" method="post">
		<input type="submit" value="Logout" name="LogoutSubmit">
	</form>
</div>
<div style="clear:both;"></div>
<hr />